require 'test/unit'
require 'm3g'

class Test_AnimationTrack < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_default_variables
    key_seq = M3G::KeyframeSequence.new 10, 3, M3G::KeyframeSequence::LINEAR
    track   = M3G::AnimationTrack.new   key_seq, M3G::AnimationTrack::COLOR

    assert_equal nil    , track.controller
    assert_equal key_seq, track.keyframe_sequence
    assert_equal M3G::AnimationTrack::COLOR, track.target_property
  end

  def test_set_variables
    ctrl    = M3G::AnimationController.new
    key_seq = M3G::KeyframeSequence.new 10, 3, M3G::KeyframeSequence::LINEAR
    track   = M3G::AnimationTrack.new   key_seq, M3G::AnimationTrack::COLOR
    track.controller = ctrl

    assert_equal ctrl   , track.controller
    assert_equal key_seq, track.keyframe_sequence
    assert_equal M3G::AnimationTrack::COLOR, track.target_property
  end

  def test_duplicate
    ctrl    = M3G::AnimationController.new
    key_seq = M3G::KeyframeSequence.new 10, 3, M3G::KeyframeSequence::LINEAR
    track1  = M3G::AnimationTrack.new   key_seq, M3G::AnimationTrack::COLOR
    track1.controller = ctrl

    track2 = track1.duplicate

    assert_not_equal track1, track2
    assert_equal ctrl   , track2.controller
    assert_equal key_seq, track2.keyframe_sequence
    assert_equal M3G::AnimationTrack::COLOR, track2.target_property
  end

  def test_references
    ctrl    = M3G::AnimationController.new
    key_seq = M3G::KeyframeSequence.new 10, 3, M3G::KeyframeSequence::LINEAR
    track   = M3G::AnimationTrack.new   key_seq, M3G::AnimationTrack::COLOR
    track.controller = ctrl

    objs = track.references

    assert_equal 2      , objs.length
    assert_equal key_seq, objs[0]
    assert_equal ctrl   , objs[1]
  end
end


